<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
    export default {
        mixins: [Vue.prototype.$vFN.Mixins.Base],
        data() {
            return {
                load:false,
                form: {
                    // 类型 1阿里，2腾讯   
                    type: 1,
                    // AccessKeyId
                    keyId:"",
                    // AccessKeySecret
                    keySecret:"",
                    // 短信签名
                    keySign:"",
                    // 注册模板编号
                    registerTemplate:"",
                    // 找回密码模板编号
                    forgetTemplate:"",
                    // 登录模板编号
                    loginTemplate:""
                },
            };
        },
        methods: {

            // 初始化
            init() {
                this.getData();
            },
            // 获取内容信息
            async getData() {
                let _data = await this.$vFN.Http.post({
                    url: "mall-admin/code-config/getItem",
                },window);
                if (_data._ok) {
                    for (let i in this.form) {
                        if(_data.data[0][i]){
                            this.form[i] = _data.data[0][i]
                        }
                        
                    }
                    this.load = true;
                }
            },
            
            // 验证 
            validate() {
                return new Promise((resolve, reject) => {
                    this.$refs["editForm"].validate((valid) => {
                        valid ? resolve(true) : resolve(false)
                    });
                });
            },
            // 提交
            async submit() {
                if (!await this.validate()) {
                    return
                }
                let _data = await this.$vFN.Http.post({
                    url: "mall-admin/code-config/saveOrUpdate",
                    data: this.form,
                },window);
                if (_data._ok) {
                    this.$vFN.Tools.messageSuccess("保存成功");
                    this.init();
                }
            },
        },
        mounted() {
            this.init();

        },
        activated() {},
    };
</script>